package com.hcl.security.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {

	@GetMapping("/hello")
	@PreAuthorize("hasAnyAuthority('h1')")
	public String hello() {
		Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
		return "Hello, World!";
	}
}
